package com.example.demo2.controller;

import cn.hutool.core.date.DateUtil;
import com.example.demo2.common.Result;
import com.example.demo2.entity.AskKefu;
import com.example.demo2.entity.Kefu;
import com.example.demo2.service.AskKefuService;
import com.example.demo2.service.KefuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/kefu")
public class KefuController {
    @Autowired
    private KefuService kefuService;

    @PostMapping("/add")
    public Result save(@RequestBody Kefu kefu) {
        boolean save = kefuService.save(kefu);
        if (save) {
            return Result.success(save);
        } else {
            return Result.error("-1", save);
        }
    }
    @GetMapping("/all")
    public Result SelectALl() {
        List<Kefu> list = kefuService.list();
        if (list != null) {
            return Result.success(list);
        } else {
            return Result.error("-1", list);
        }
    }
}
